#include "BigInt.hpp"
namespace myh{
    class Fraction{
    private:
        BigInt numerator,denominator;
    public:
        Fraction(const BigInt& numerator_,const BigInt& denominator_){
            BigInt g=gcd(numerator,denominator);
            numerator=numerator_/g;
            denominator=numerator_/g;
        }
        Fraction(const BigInt& numerator):numerator(numerator),denominator(1){}
        Fraction():numerator(0),denominator(1){}
        Fraction operator+(const Fraction& other) const {
            return Fraction(numerator*other.denominator+other.numerator*denominator,denominator*other.denominator);
        }
        Fraction operator-(const Fraction& other) const {
            return Fraction(numerator*other.denominator-other.numerator*denominator,denominator*other.denominator);
        }
        Fraction operator*(const Fraction& other) const {
            return Fraction(numerator*other.numerator,denominator*other.denominator);
        }
        Fraction operator/(const Fraction& other) const {
            return Fraction(numerator*other.denominator,denominator*other.numerator);
        }
        Fraction operator-() const {
            return Fraction(-numerator,denominator);
        }
        Fraction operator+() const {
            return *this;
        }
        bool operator==(const Fraction& other) const {
            return numerator*other.denominator==other.numerator*denominator;
        }
        bool operator!=(const Fraction& other) const {
            return !(*this==other);
        }
        bool operator<(const Fraction& other) const {
            return numerator*other.denominator<other.numerator*denominator;
        }
        bool operator>(const Fraction& other) const {
            return (other<*this);
        }
        bool operator<=(const Fraction& other) const {
            return !(other<*this);
        }
        bool operator>=(const Fraction& other) const {
            return !(*this<other);
        }
        BigInt getNum() const {
            return numerator;
        }
        BigInt getDen() const {
            return denominator;
        }
        friend std::ostream& operator<<(std::ostream& os,const Fraction& fraction){
            if(fraction.denominator==1) os<<fraction.numerator;
            else os<<fraction.numerator<<'/'<<fraction.denominator;
            return os;
        }
    };
}